package com.jfl.core.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 资源配置
 *  
 * @author  赵炎
 * @version  [V1.00, 2019年7月17日]
 * @see  [相关类/方法]
 * @since V1.00
 */
@Configuration
public class ResourcesConfig implements WebMvcConfigurer
{
    /**
     * 登录地址
     */
    @Value("${jfl.shiro.user.loginUrl}")
    private String loginUrl;
    
    @Value("${jfl.image.path}")
    private String avatarPath;
    /**
     * 默认首页的设置，当输入域名是可以自动跳转到默认指定的网页
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry)
    {
        registry.addViewController("/").setViewName("forward:" + loginUrl);
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry)
    {
        /** 文件上传路径 */
        registry.addResourceHandler("/profile/**").addResourceLocations("file:" + avatarPath);
    }
  
}
